// $Id$

#include "PreCompile.h"
#include "IoCpp/Configuration.h"
#include "IoCpp/Container.h"
#include "IoCpp/Detail/ConfigRegistry.h"
#include "IoCpp/Detail/Resolver.h"

#include <boost/shared_ptr.hpp>

using namespace IoCpp;
using namespace IoCpp::Detail;


namespace
{
   // The global registry.
   ConfigRegistry& GetRegistry() 
   {
      static ConfigRegistry registry;
      return registry;
   }

   // The global resolver.
   Resolver& GetResolver() 
   {
      static Resolver resolver;
      return resolver;
   }
}


void Container::Configure() {
   GetRegistry().Configure(Configuration(GetResolver()));
}


const Injector& Container::GetInjector() {
   return GetResolver().GetInjector();
}


RegisterConfigProvider::RegisterConfigProvider( ConfigProvider provider ) {
   GetRegistry().AddConfiguration(provider);
}
